<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:th='http://www.thymeleaf.org'>

<head>
	<meta charset='UTF-8'/>
	<link rel='stylesheet' type='text/css' href='themes/material/easyui.css'/>
	<link rel='stylesheet' type='text/css' href='themes/icon.css'/>
	<link rel='stylesheet' type='text/css' href='css/style.css'/>
</head>

<body>
	<div id='toolbar' class='top'><ul style='padding-left:5px'><li th:each='btn:${btnlist}'>
		<a href='#' class='easyui-linkbutton' plain='true' onclick='' th:attrappend='onclick=${btn.btnfunc}'>
		<i class='fa fa-' th:attrappend='class=${btn.btnicon}'></i>&nbsp;<span th:text='${btn.btnname}'></span></a></li></ul>
	</div>
	<div id='common-dialog' class='easyui-dialog' modal='true' closed='true' style='display:none;width:325px;height:380px'>
		<div class='easyui-layout' fit='true'>
			<form id='common-form' class='easyui-form' method="post">
				<input type='hidden' name='id'/>
				<div region='center' border='false'><div class='centerdiv'>
				<table>
					<tr><td><label>菜单名称：</label>
					<input class='easyui-textbox' name='menuname' data-options='required:true'/></td></tr>
					<tr><td><label>上级菜单：</label>
					<select name="parentid"  id="pmenu"></select></td></tr>
					<tr><td><label>模块路径：</label>
					<input class='easyui-textbox' name='menupath' data-options='required:true'/></td></tr>
					<tr><td><label>图标样式：</label>
					<input class='easyui-textbox' name='menuicon' data-options='required:true'/></td></tr>
					<tr><td><label>是否显示：</label>
					<select class="easyui-combobox" name="menushow" data-options="required:true,editable:false">
				    <option value="0">是</option><option value="1">否</option></select></td></tr>
					<tr><td><label>展现顺序：</label>
					<input class='easyui-numberbox' name='menuorder' data-options='required:true'/></td></tr>
				</table></div></div>
				<div region='south' border='false' class='southdiv'>
				<a class='easyui-linkbutton' icon='fa fa-check-square-o' href='#' onclick="common_submit(-1,'',1)">保存</a>
				<a class='easyui-linkbutton' icon='fa fa-undo' href='#' onclick='common_reset()'>重置</a>
		</div></form></div>
	</div>
	<table id='common-table'></table>
	<ul id="spmenu"></ul>
	<script type='text/javascript' src='jquery.min.js'></script>
	<script type='text/javascript' src='jquery.easyui.min.js'></script>
	<script type='text/javascript' src='js/util.js'></script>
	<script>
		$(function(){
			$('#common-table').treegrid({
				border:false,
				rownumbers: true,
				fitColumns: true,
				fit:true,
				url: '/d/menulist',
				method: 'post',
				idField: 'id',
				treeField: 'menuname',
				striped : true,
				pagination:true,
				pageSize:25,
				pageList:[25,50],
				toolbar:'#toolbar',
				singleSelect:true,
				columns:[[
					{title:'选择',field:'id',checkbox:true},
					{title:'菜单名称',field:'menuname',align:'left',width:100},
					{title:'上级菜单',field:'parentname',align:'center',width:100},
					{title:'模块路径',field:'menupath',align:'center',width:200},
					{title:'图标样式',field:'menuicon',align:'center',width:100},
					{title:'是否显示',field:'menushow',align:'center',width:100,
						formatter: function(value,row,index){
							if(value == 0)
								return '是';
							else if(value == 1)
								return '否';
							else
								return value;
						}
					},
					{title:'展现顺序',field:'menuorder',align:'center',width:100},
				]],
				onClickRow:function(row){
					$('#common-table').treegrid('expandAll', row.id);
				}
			})
			$('#pmenu').combo({
				required:true,
				editable:false,
				prompt:'请选择上级菜单'
			});
			$('#spmenu').appendTo($('#pmenu').combo('panel'));
			$('#spmenu').tree({
				url : '/d/menuComBox',
				animate:true,
				lines:true,
				onClick:function(node){
					$('#pmenu').combo('setValue', node.id).combo('setText', node.text).combo('hidePanel');
				}
			});
		});
		function add(){
			common_add('新增','/d/menusave');
		}
		function edit(){
			common_edit('编辑','/d/menuedit');
		}
		function del(){
			common_delete('/d/menudel',2,'包含下级菜单，不可删除！',1);
		}
		function btn(){
	  		var row = $('#common-table').datagrid('getSelected');
	  		if (row == null) {
				$.messager.alert('提示', '请先选择一个菜单！','info');
				return;
			}
	        parent.addTab(row.menuname+'按钮','menubtn?mid='+row.id);
	    }
	</script>
</body>
</html>
